﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class Admin_TKDonDatHang : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            OracleConnection con = DataConnection.TaoKetNoi();

            DataSet2 ds = new DataSet2();
            OracleDataAdapter adapter = new OracleDataAdapter("select sach.masach, sach.tensach, sach.tacgia,sach.dongia, count(chitietdonhang.soluong) as TongSoLuongBan from sach, chitietdonhang,donhang where donhang.madonhang=chitietdonhang.madonhang and  sach.masach = chitietdonhang.masach and donhang.tinhtrang=0 GROUP BY SACH.masach, sach.tensach,sach.tacgia, sach.dongia", con);
            adapter.Fill(ds.VIEWSACHDAT);


            ReportDocument rptDoc = new ReportDocument();
            rptDoc.Load(Server.MapPath("CrystalReportDatHang.rpt"));
            rptDoc.SetDataSource(ds);

            CrystalReportViewer2.ReportSource = rptDoc;
        }
        catch (Exception)
        {

            Response.Redirect("thongbao.aspx?ID=5");
        }


    }
}